package com.myc.train.batch.job;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.myc.train.batch.feign.BusinessFeign;
import com.myc.train.common.resp.CommonResp;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;


public class DailyTrainJob implements Job {

    @Autowired
    private BusinessFeign businessFeign;
    private static final Logger LOG = LoggerFactory.getLogger(DailyTrainJob.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        LOG.info("生成车次");

        Date date = new Date();
        DateTime offset = DateUtil.offsetDay(date, 15);
        Date date1 = offset.toJdkDate();
        CommonResp<Object> CommonResp = businessFeign.genDaily(date1);
        LOG.info("生成车次完成。。。。。。{}",CommonResp);
    }
}
